<template>
    <div class="app-container">
        <!-- 主内容区 -->
        <main class="main-content">
            <div>
                <!-- 快捷功能区 -->
                <div class="quick-access">
                    <div class="section-title">快捷功能</div>
                    <div class="quick-grid">
                        <div v-for="(item, index) in quickActions" :key="index"
                            :class="['quick-item', { 'quick-item-active': selectedIndex === index }]">
                            <div @click="toUrl(item, index)" class="toUrl">
                                <div class="quick-icon">
                                    <i :class="item.icon"></i>
                                </div>
                                <span class="quick-text">{{ item.name }}</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <router-view></router-view>
        <el-drawer v-model="showChat" title="我是标题" :with-header="false">
            <AiChat />
        </el-drawer>
    </div>
</template>

<script lang="ts" setup>
import router from '@/router';
import { ref } from 'vue';
import AiChat from "../../components/AiChat.vue"

// 控制AI聊天框显示状态
const showChat = ref(false);
// 跟踪当前选中的快捷功能项索引
const selectedIndex = ref(-1);

const quickActions = [
    { name: '大厅', icon: 'fas fa-hospital fa-2x', url: "/CommunityHealthcare/default" },
    { name: '预约挂号', icon: 'fas fa-hospital fa-2x', url: "/CommunityHealthcare/MakeAppointment" },
    // { name: '在线问诊', icon: 'fas fa-user-md fa-2x', url: "/CommunityHealthcare/ChatComponent" },
    // { name: '健康档案', icon: 'fas fa-file-medical-alt fa-2x', url: "/MakeAppointment" },
    // { name: 'AI聊天', icon: 'fas fa-file-medical-alt fa-2x', url: "ai_chat" },
    { name: '病历上传工具', icon: 'fas fa-pills fa-2x', url: "/CommunityHealthcare/uploadFunction" },
    { name: '智能问答', icon: 'fas fa-pills fa-2x', url: "/CommunityHealthcare/mcpcontent" },
];

// 处理快捷功能点击事件，添加index参数
function toUrl(item: any, index: number) {
    // 更新选中索引
    selectedIndex.value = index;

    if (item.url == "ai_chat") {
        showChat.value = true;
        return;
    }
    router.push(item.url);
}
</script>

<style scoped>
.app-container {
    min-height: 100vh;
    background-color: #f5f7fa;
}

.header {
    height: 60px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #2c5282;
}

.logo-text {
    font-size: 20px;
    font-weight: bold;
}

.toUrl {
    width: 100%;
    height: 100%;
}

.header-right {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

.main-container {
    display: flex;
    padding-top: 60px;
    min-height: calc(100vh - 60px);
}

.side-nav {
    width: 200px;
    background-color: #fff;
    padding: 24px 0;
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    gap: 12px;
}

.nav-item:hover {
    background-color: #e6f0ff;
    color: #2c5282;
}

.nav-item.active {
    background-color: #e6f0ff;
    color: #2c5282;
    border-right: 3px solid #2c5282;
}

.main-content {
    padding: 24px;
}

.section-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #2d3748;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.quick-item {
    background-color: #fff;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.quick-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.quick-icon {
    color: #2c5282;
    margin-bottom: 12px;
}

.quick-text {
    font-size: 16px;
}

/* 选中状态样式 */
.quick-item-active {
    border: 2px solid #2c5282;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 82, 130, 0.2);
}

.quick-item-active .quick-icon {
    color: #2c5282;
    transform: scale(1.1);
}

.quick-item-active .quick-text {
    color: #2c5282;
    font-weight: bold;
}

/* 平滑过渡效果 */
.quick-item,
.quick-icon {
    transition: all 0.3s ease;
}

.health-reminder {
    background-color: #fff;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.reminder-content {
    display: flex;
    gap: 20px;
}

.reminder-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 8px;
}

.reminder-item i {
    font-size: 24px;
    color: #2c5282;
}

.reminder-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 4px;
}

.reminder-detail {
    color: #64748b;
}

.recent-visits {
    background-color: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.visits-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.visit-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 8px;
}

.visit-date {
    width: 120px;
    font-weight: bold;
}

.visit-info {
    flex: 1;
}

.visit-department {
    font-weight: bold;
    margin-bottom: 4px;
}

.visit-doctor {
    color: #64748b;
}

.visit-status {
    padding: 4px 12px;
    background-color: #e6f0ff;
    color: #2c5282;
    border-radius: 4px;
}

/* Health Records Styles */
.section-container {
    background-color: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.records-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.record-card {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.record-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    color: #2c5282;
}

.record-header h3 {
    font-size: 18px;
    font-weight: bold;
}

.info-item {
    margin-bottom: 12px;
    font-size: 16px;
}

.info-label {
    color: #64748b;
    margin-right: 8px;
}

.record-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.record-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background-color: #f8fafc;
    border-radius: 6px;
}

.record-date {
    width: 100px;
    font-size: 14px;
    color: #64748b;
}

.record-main {
    flex: 1;
}

.record-type {
    font-weight: bold;
    margin-bottom: 4px;
}

.record-value {
    color: #2c5282;
}

.record-status {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.status-normal {
    background-color: #e6ffea;
    color: #059669;
}

.status-alert {
    background-color: #fff1f2;
    color: #be123c;
}

/* Payment Styles */
.payment-alert {
    padding: 8px 16px;
    background-color: #fff1f2;
    border-radius: 6px;
    color: #be123c;
    font-size: 16px;
}

.payment-alert .amount {
    font-weight: bold;
    margin-left: 4px;
}

.payment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.payment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 8px;
}

.payment-info {
    display: flex;
    align-items: center;
    gap: 24px;
}

.payment-date {
    width: 100px;
    color: #64748b;
}

.payment-type {
    width: 120px;
    font-weight: bold;
}

.payment-amount {
    font-size: 18px;
    font-weight: bold;
    color: #2c5282;
}

.payment-action {
    display: flex;
    align-items: center;
    gap: 16px;
}

.payment-status {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.status-pending {
    background-color: #fff1f2;
    color: #be123c;
}

.status-paid {
    background-color: #e6ffea;
    color: #059669;
}

.pay-button {
    padding: 8px 16px;
    background-color: #2c5282;
    color: white;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.pay-button:hover {
    background-color: #1e3a5f;
}

/* Reports Styles */
.reports-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.report-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 8px;
}

.report-info {
    display: flex;
    align-items: center;
    gap: 24px;
}

.report-date {
    width: 100px;
    color: #64748b;
}

.report-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-type {
    font-weight: bold;
}

.report-department {
    color: #64748b;
}

.report-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.report-status {
    color: #059669;
}

.view-report-button {
    padding: 8px 16px;
    background-color: #2c5282;
    color: white;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.view-report-button:hover {
    background-color: #1e3a5f;
}
</style>